home *** CD-ROM | disk | FTP | other *** search
/ Aminet 32 / Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso / Aminet / dev / lang / Python151_Src.lha / Python1.5_Source / Amiga / _lseek.c < prev    next >
C/C++ Source or Header  |  1994-09-30  |  1KB  |  58 lines

  1. RCS_ID_C="$Id: _lseek.c,v 4.1 1994/09/29 23:09:02 jraja Exp $";
  2. /*
  3.  *      _lseek.c - lseek() which knows sockets (SAS/C)
  4.  *
  5.  *      Copyright © 1994 AmiTCP/IP Group, 
  6.  *                       Network Solutions Development Inc.
  7.  *                       All rights reserved.
  8.  */
  9.  
  10. #include <ios1.h>
  11. #include <fcntl.h>
  12. #include <stdlib.h>
  13. #include <dos.h>
  14. #include <errno.h>
  15. #include <dos/dos.h>
  16. #include <proto/dos.h>
  17.  
  18. long
  19. __lseek(int fd, long rpos, int mode)
  20. {
  21.   struct UFB *ufb;
  22.   long        apos;
  23.  
  24.   /*
  25.    * Check for the break signals
  26.    */
  27.   __chkabort();
  28.   /*
  29.    * find the ufb *
  30.    */
  31.   if ((ufb = __chkufb(fd)) == NULL) {
  32.     errno = EINVAL;
  33.     return -1;
  34.   }
  35.   
  36.   _OSERR = 0;
  37.  
  38.   if (ufb->ufbflg & UFB_SOCK) {
  39.     errno = ESPIPE; /* illegal seek */
  40.     return -1;
  41.   }
  42.  
  43.   if ((apos = Seek(ufb->ufbfh, rpos, mode - 1)) == -1) {
  44.     _OSERR = IoErr();
  45.     errno = EIO;
  46.     return -1;
  47.   }
  48.   
  49.   switch (mode) {
  50.   case 0:
  51.     return rpos;
  52.   case 1:
  53.     return apos + rpos;
  54.   case 2:
  55.     return Seek(ufb->ufbfh, 0, 0);
  56.   }
  57. }
  58.